home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / art&graf.ix / art-0015 / flicker / disk.asm < prev    next >
Assembly Source File  |  1997-04-16  |  2KB  |  83 lines

  1.     public _plot
  2.     public _ahline
  3.     public _aline
  4.  
  5. ; useful aline offsets
  6. x1        equ    38
  7.  
  8. ;clipping constants
  9. XMAX    equ    320    
  10. YMAX    equ    200
  11.  
  12.     public _disk
  13. _disk
  14. param1    equ    7*4+4    ; offset on stack to first parameter after register saved
  15. x        equ    param1
  16. y        equ  param1+2
  17. rad     equ    param1+4
  18. color     equ param1
  19.     movem.l    d3/d4/d5/d6/d7/a2/a3,-(sp)
  20.  
  21.     move.w    x(sp),d6    ; save center xy
  22.     move.w    y(sp),d7
  23.     move.w    rad(sp),d4    ; xoffset starts out radius
  24.     bne        nontrivd    ; it's not zero radius...do a disk
  25.     move.w    d6,(sp)
  26.     move.w    d7,2(sp)
  27.     jsr        _plot        ; else just plot one point... 
  28.     bra        enddloop
  29. nontrivd
  30.     move.l    _aline,a3    ; get "aline" pointer
  31.     add.l    #x1,a3        ; and move it to the x1,y1,x2 area
  32.     move.w    #0,d5        ; yoffset starts out zero
  33.     move.w    d4,d3
  34.     neg.w    d3
  35.     asr.w    #1,d3        ; d3 = error = -rad/2
  36.  
  37.  
  38. dloop
  39.     ;    plot upper line
  40.     move.w    d6,d0    
  41.     sub.w    d4,d0    ;     find left side of hline
  42.     bpl        lclipok    ;    off screen to left?
  43.     move.w    #0,d0    ;   then make it start on left edge
  44. lclipok    move.w    d0,(a3)    ; save left edge in aline structure "x1"
  45.     move.w    d6,d0    
  46.     add.w    d4,d0
  47.     cmp.w    #XMAX,d0    ; calculate right edge and see if offscreen
  48.     blt        rclipok
  49.     move.w    #XMAX-1,d0    ; if offscreen make it end on right edge
  50. rclipok    move.w    d0,4(a3) ; and save right edge in aline structure "x2"
  51.     move.w    d7,d0
  52.     sub.w    d5,d0    ;   calculate absolute y coordinate
  53.     bmi        lline    ;    clipped above screen?
  54.     move.w    d0,2(a3) ;     and save y position in "y1" slot of aline structure
  55.     dc.w $a004    ; call aline horizontal line
  56.  
  57. lline
  58.     move.w    d7,d0
  59.     add.w    d5,d0    ; calc y coordinate of lower line
  60.     cmp.w    #YMAX,d0
  61.     bge        nextxy    ; if below screen don't plot it
  62.     move.w    d0,2(a3)
  63.     dc.w    $a004    ; and draw 2nd horizontal line
  64.  
  65.     ; now do stuff to figure out where next hlines will be
  66. nextxy
  67.     tst.w    d3        ; check sign of error term
  68. nexty
  69.     bmi        stepy
  70.     subq.w    #1,d4
  71.     bmi        enddloop
  72.     sub.w    d4,d3
  73.     bra        nexty
  74. stepy
  75.     addq.w    #1,d5    ; increment y offset
  76.     add.w    d5,d3    ; update error term
  77.     bra     dloop
  78.  
  79. enddloop
  80.     movem.l    (sp)+,d3/d4/d5/d6/d7/a2/a3
  81.     rts
  82.  
  83.